package com.xcity.game.item;

import naga.x.game.template.TemplateException;
import naga.x.game.template.annotation.Excel;

@Excel(value = "item.xlsx", sheet = 0)
public class GameItemTemplate extends ItemTemplate {

	/** 是否自动使用(0:否; 1:是) */
	protected boolean autoUse;

	/** 使用目标(-1:没有目标;0:自己;1:好友;2:非好友;3:仇人;4:别人) */
	protected byte target;
	
	/** 使用效果 */
	protected int effect;

	/** 使用效果参数 */
	protected int[] params;

	public boolean isAutoUse() {
		return autoUse;
	}

	public void setAutoUse(boolean autoUse) {
		this.autoUse = autoUse;
	}

	public byte getTarget() {
		return target;
	}

	public void setTarget(byte target) {
		this.target = target;
	}

	public int getEffect() {
		return effect;
	}

	public void setEffect(int effect) {
		this.effect = effect;
	}

	public int[] getParams() {
		return params;
	}

	public void setParams(int[] params) {
		this.params = params;
	}

	@Override
	public void validate() throws TemplateException {
		// 检测一遍使用效果
		if (target != Item.TARGET_NONE && ItemEffectFactory.create(this) == null) {
			target = Item.TARGET_NONE;
		}
		// 宠物粮食不能在背包中使用
		if (effect == ItemEffect.ADD_PET_SPIRIT) {
			target = Item.TARGET_NONE;
		}
	}
	
}
